package greedy;

/**
 * Created with IntelliJ IDEA.
 * Description: 55. 跳跃游戏
 * User: Li_yizYa
 * Date: 2025/6/24
 * Time: 21:41
 */
public class Solution5 {
    public boolean canJump(int[] nums) {
        if (nums == null || nums.length == 0) {
            return false;
        }
        if (nums.length == 1) {
            return true;
        }
        int coverRange = 0;
        for (int i = 0; i <= coverRange; i++) {
            coverRange = Math.max(coverRange, i + nums[i]);
            if (coverRange >= nums.length - 1) {
                return true;
            }
        }
        return false;
    }
}
